<?php

namespace app\common\service;

use app\common\model\Fans;
use app\http\exception\ApiException;

class FansService extends BaseService
{

        public static function getFansList( $data ){
            return Fans::build()->orderBy('fans_id' , 'desc')->select();
        }

        public static function getFansItem( $id ){
            return Fans::build()->findOrFail($id);
        }

        public static function delFansItem( Fans $Fans ){
            return $Fans->delete();
        }

    	public static function setFansItem(Fans $Fans, $data){
            $Fans->save($data);
            return $Fans;
        }


        public static function addFansItem($data)
        {
            $model = new Fans();
            return $model->save($data);
        }

    public function authUserInfo(string $fans_id, array $userInfo)
    {
        $fans = Fans::build()->findOrFail($fans_id);
        $fans->head_pic = $userInfo['head_pic'];
        $fans->nickname = $userInfo['nickname'];
        return $fans->save();
    }
}
